﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using MpSoft.Library.BUSS.Contents;
using MpSoft.Basic.Utils;
using MpSoft.Library.CommonLibrary;

namespace MpSoft.Web.Controls.News
{
    public partial class BarNewsByCategory : UserControl
    {
        #region Var
        #endregion

        #region Method

        protected string GetNewsByCategory()
        {
            var list = NewsBUSS.News_List(this.CategoryID, 1, 1);
            if (list != null)
            {
                StringBuilder sb = new StringBuilder();
                var url = string.Empty; 
                foreach (var obj in list)
                {
                    url = string.Format(obj.FormatUrl, obj.NewsID);
                    sb.Append("<a href='" + url + "'><img src='" + obj.Image + "'/> <span class='tit'>" + obj.Title + "</span><span>" + Extends.SubString(obj.Description, 90) + "</span></a>");
                }
                return sb.ToString();
            }
            return "";
        }

        private void BindControl()
        {
            
        }

        #endregion

        #region Event

        protected void Page_Load(object sender, EventArgs e)
        {
            BindControl();
        }
        #endregion

        #region Properties

        public int CategoryID
        { set; get; }

        #endregion
    }
}